package cn.lili.controller.order;

import cn.lili.common.aop.annotation.PreventDuplicateSubmissions;
import cn.lili.common.utils.ResultUtil;
import cn.lili.common.vo.ResultMessage;
import cn.lili.modules.order.order.service.VipOrderService;
import cn.lili.modules.order.order.entity.dos.VipOrder;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotNull;

@RestController
@RequestMapping("/order/vip")
@Api(tags = "plus会员订单")
@RequiredArgsConstructor
public class VipOrderController {

    private final VipOrderService vipOrderService;

    @PreventDuplicateSubmissions
    @PostMapping
    @ApiOperation(value = "创建会员购买订单")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "price", value = "购买金额", required = true, dataType = "double", paramType = "query")
    })
    public ResultMessage<VipOrder> create() {
        VipOrder vipOrder = this.vipOrderService.createOrder();
        return ResultUtil.data(vipOrder);
    }
}
